<template>
  <el-container direction="vertical">
    <my-file-apply-dialog :fileId="currentFileId" :file-info="currentFileInfo" :visible.sync="applyVisible"  @close="dialogClose"></my-file-apply-dialog>
    <el-table
      :data="tableData"
      border
      style="width: 100%"
      size="mini">
      <el-table-column
        prop="id"
        label="ID"
        min-width="20%">
      </el-table-column>
      <el-table-column
        prop="fileName"
        label="文件名"
        min-width="10%">
      </el-table-column>
      <el-table-column
        prop="createdTime"
        label="创建时间"
        min-width="20%">
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        min-width="20%">
        <template slot-scope="scope">
          <el-button @click="contributePage(scope.row)" type="text" size="small">查看贡献申请</el-button>
          <el-button type="text" @click="detail(scope.row)" size="small">查看</el-button>
          <el-button type="text" @click="deleteFile(scope.row)" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      style="padding: 10px 10px 5px 10px;"
      :current-page="pageData.current"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :page-size="pageData.size"
      layout="total, prev, pager, next, jumper"
      :total="total"
    />
  </el-container>
</template>

<script>
  import MyFileApplyDialog from './MyFileApplyDialog'
  export default {
    name: 'index',
    components: { MyFileApplyDialog },
    data: function() {
      return {
        tableData: [],
        pageData: {
          current: 1,
          size: 10,
        },
        total: 0,
        currentFileId: null,
        applyVisible: false,
        currentFileInfo: null,
      }
    },
    created() {
      this.getMyFilePage();
    },
    methods: {
      contributePage(row) {
        this.currentFileId = row.id;
        this.applyVisible = true;
        this.currentFileInfo = row;
      },
      detail(row) {

      },
      deleteFile(row) {

      },
      getMyFilePage() {
        this.$api.currentUserFilePage(this.pageData).then(res => {
          this.tableData = res.records;
          this.total = res.total;
        })
      },
      handleSizeChange(val) {
        this.pageData.size = val;
        this.getMyFilePage();
      },
      handleCurrentChange(val) {
        this.pageData.current = val;
        this.getMyFilePage();
      },
      dialogClose() {
        // console.log(1211);
        this.applyVisible = false;
      }
    }
  }
</script>

<style scoped>

</style>
